<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/28
 * Time: 9:35
 */

namespace app\admin\controller;


use cmf\controller\AdminBaseController;

class CommentController extends AdminBaseController
{

    public function index()
    {

        $list = db('guanwang_comment')->where('is_del', 0)->order('status asc')->order("create_time desc")->paginate(20);

        $page = $list->render();

//        dump($list);die;
        return $this->fetch('', array(
            'list' => $list,
            'page' => $page
        ));
    }

    public function updateStatus()
    {
        $id = $this->request->param('id', '', 'intval');

        $result = db('guanwang_comment')->where('id', $id)->update(array('status'=>1));

        if (!$result){
            $this->error('网络繁忙，请稍后');
        }

        $this->success('修改成功');
    }

    public function delete()
    {
        $id = $this->request->param('id', '', 'intval');

        $result = db('guanwang_comment')->where('id', $id)->update(array('is_del'=>1));

        if (!$result){
            $this->error('网络繁忙，请稍后');
        }

        $this->success('删除成功');
    }
}